package com.neusoft.elmboot.service.impl;

import com.neusoft.elmboot.mapper.CommentMapper;
import com.neusoft.elmboot.po.Comment;
import com.neusoft.elmboot.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    CommentMapper commentMapper;

    @Override
    public void createComment(Comment comment) {
        commentMapper.createComment(comment);
    }

    @Override
    public List<Integer> getCommentIdByUserId(String userId) {
        return commentMapper.getCommentIdByUserId(userId);
    }

    @Override
    public void delCommentUser(List<Integer> commentIdList) {
        commentMapper.delCommentUser(commentIdList);
    }

    @Override
    public List<Comment> showComments(String businessId) {
        return commentMapper.getCommetByBusinessId(businessId);

//        List<CommentVO> commentVOList = new ArrayList<>();
//        for (Comment comment : commentList) {
//            CommentVO commentVO = new CommentVO(comment);
//            commentVOList.add(commentVO);
//        }
//
//        return commentVOList;
    }

    @Override
    public Double getAverageRatingByBusinessId(String businessId) {
        return commentMapper.getAverageRatingByBusinessId(businessId);
    }
}
